<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select :disabled="scene == 0 ? false : true" v-model="catagoryStore.c1Id" @change="handler">
          <el-option v-for="c1 in catagoryStore.c1Arr" :key="c1.id" :label="c1.name" :value="c1.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select :disabled="scene == 0 ? false : true" v-model="catagoryStore.c2Id" @change="handler1">
          <el-option v-for="c2 in catagoryStore.c2Arr" :key="c2.id" :label="c2.name" :value="c2.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select :disabled="scene == 0 ? false : true" v-model="catagoryStore.c3Id">
          <el-option v-for="c3 in catagoryStore.c3Arr" :key="c3.id" :label="c3.name" :value="c3.id"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import useCategoryStore from '@/store/modules/catagory'
let catagoryStore = useCategoryStore()
onMounted(() => {
  getC1()
})
const getC1 = () => {
  catagoryStore.getC1()
}

const handler = () => {
  catagoryStore.c2Id = ''
  catagoryStore.c3Arr = []
  catagoryStore.c3Id = ''
  catagoryStore.getC2()
}

const handler1 = () => {
  catagoryStore.c3Id = ''
  catagoryStore.getC3()
}

defineProps(['scene'])
</script>

<style scoped></style>
